package net.galacticwar.replayserver.admin;
import javax.swing.BorderFactory;
import javax.swing.DefaultListModel;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.LayoutStyle;
import javax.swing.ListModel;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class PropertyFrame extends javax.swing.JFrame {
	private JButton quitButton;

	private JCheckBox filterCheckBox;
	private JScrollPane jScrollPane1;
	private JScrollPane jScrollPane2;
	private JLabel versionLbl;
	private JButton refreshButton;
	private JButton replayListenersButton;
	private JButton replayDetailsButton;
	private JButton loadReplayButton;
	private JButton closeServerButton;
	private JButton closeReplayButton;
	private JList replayList;
	private JButton removePlayerButton;
	private JButton addPlayerButton;
	private JPanel replayPanel;
	private JPanel filterPanel;
	private JList nameList;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				PropertyFrame inst = new PropertyFrame();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public PropertyFrame() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			GroupLayout thisLayout = new GroupLayout((JComponent)getContentPane());
			getContentPane().setLayout(thisLayout);
			thisLayout.setVerticalGroup(thisLayout.createSequentialGroup()
				.addContainerGap()
				.addComponent(getReplayPanel(), GroupLayout.PREFERRED_SIZE, 239, GroupLayout.PREFERRED_SIZE)
				.addGap(17)
				.addComponent(getFilterPanel(), GroupLayout.PREFERRED_SIZE, 200, GroupLayout.PREFERRED_SIZE)
				.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
				.addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
				    .addComponent(getCloseServerButton(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 29, GroupLayout.PREFERRED_SIZE)
				    .addComponent(getRefreshButton(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 27, GroupLayout.PREFERRED_SIZE))
				.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
				.addComponent(getQuitButton(), GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE)
				.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
				.addComponent(getVersionLbl(), 0, 14, Short.MAX_VALUE)
				.addGap(8));
			thisLayout.setHorizontalGroup(thisLayout.createSequentialGroup()
				.addContainerGap()
				.addGroup(thisLayout.createParallelGroup()
				    .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
				        .addComponent(getCloseServerButton(), GroupLayout.PREFERRED_SIZE, 145, GroupLayout.PREFERRED_SIZE)
				        .addGap(219))
				    .addComponent(getReplayPanel(), GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 362, GroupLayout.PREFERRED_SIZE)
				    .addComponent(getFilterPanel(), GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 362, GroupLayout.PREFERRED_SIZE)
				    .addGroup(thisLayout.createSequentialGroup()
				        .addGap(137)
				        .addGroup(thisLayout.createParallelGroup()
				            .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
				                .addGap(0, 0, Short.MAX_VALUE)
				                .addComponent(getQuitButton(), GroupLayout.PREFERRED_SIZE, 100, GroupLayout.PREFERRED_SIZE)
				                .addComponent(getRefreshButton(), GroupLayout.PREFERRED_SIZE, 127, GroupLayout.PREFERRED_SIZE))
				            .addGroup(thisLayout.createSequentialGroup()
				                .addGap(0, 0, GroupLayout.PREFERRED_SIZE)
				                .addComponent(getVersionLbl(), 0, 227, Short.MAX_VALUE)))))
				.addContainerGap());
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			this.setTitle("Live Replay Admin tool");
			this.setResizable(false);
			{

			}
			pack();
			this.setSize(394, 597);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public JCheckBox getFilterCheckBox() {
		if(filterCheckBox == null) {
			filterCheckBox = new JCheckBox();
			filterCheckBox.setText("Filter enabled");
			filterCheckBox.setBounds(17, 29, 115, 20);
		}
		return filterCheckBox;
	}
	
	public JButton getQuitButton() {
		if(quitButton == null) {
			quitButton = new JButton("Quit");
		}
		return quitButton;
	}
	
	public JList getNameList() {
		if(nameList == null) {
			ListModel nameListModel = 
				new DefaultListModel();
			nameList = new JList();
			nameList.setModel(nameListModel);
			nameList.setPreferredSize(new java.awt.Dimension(20, 20));
		}
		return nameList;
	}
	
	private JScrollPane getJScrollPane1() {
		if(jScrollPane1 == null) {
			jScrollPane1 = new JScrollPane();
			jScrollPane1.setBounds(144, 19, 201, 143);
			jScrollPane1.setViewportView(getNameList());
		}
		return jScrollPane1;
	}
	
	private JPanel getFilterPanel() {
		if(filterPanel == null) {
			filterPanel = new JPanel();
			GroupLayout filterPanelLayout = new GroupLayout((JComponent)filterPanel);
			filterPanel.setLayout(filterPanelLayout);
			filterPanel.setBorder(BorderFactory.createTitledBorder("Filter"));
			filterPanelLayout.setHorizontalGroup(filterPanelLayout.createSequentialGroup()
				.addContainerGap()
				.addGroup(filterPanelLayout.createParallelGroup()
				    .addComponent(getFilterCheckBox(), GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 115, GroupLayout.PREFERRED_SIZE)
				    .addComponent(getAddPlayerButton(), GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 116, GroupLayout.PREFERRED_SIZE)
				    .addComponent(getRemovePlayerButton(), GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 116, GroupLayout.PREFERRED_SIZE))
				.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
				.addComponent(getJScrollPane1(), GroupLayout.PREFERRED_SIZE, 201, GroupLayout.PREFERRED_SIZE)
				.addContainerGap());
			filterPanelLayout.setVerticalGroup(filterPanelLayout.createParallelGroup()
				.addGroup(GroupLayout.Alignment.LEADING, filterPanelLayout.createSequentialGroup()
				    .addComponent(getJScrollPane1(), GroupLayout.PREFERRED_SIZE, 143, GroupLayout.PREFERRED_SIZE)
				    .addContainerGap(33, 33))
				.addGroup(GroupLayout.Alignment.LEADING, filterPanelLayout.createSequentialGroup()
				    .addGap(10)
				    .addComponent(getFilterCheckBox(), GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
				    .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
				    .addComponent(getAddPlayerButton(), GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				    .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
				    .addComponent(getRemovePlayerButton(), GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
				    .addContainerGap(85, 85)));
		}
		return filterPanel;
	}
	
	private JPanel getReplayPanel() {
		if(replayPanel == null) {
			replayPanel = new JPanel();
			GroupLayout replayPanelLayout = new GroupLayout((JComponent)replayPanel);
			replayPanel.setLayout(replayPanelLayout);
			replayPanel.setBorder(BorderFactory.createTitledBorder("Replays"));
			replayPanelLayout.setHorizontalGroup(replayPanelLayout.createSequentialGroup()
				.addContainerGap()
				.addGroup(replayPanelLayout.createParallelGroup()
				    .addGroup(replayPanelLayout.createSequentialGroup()
				        .addGap(0, 0, GroupLayout.PREFERRED_SIZE)
				        .addComponent(getReplayListenersButton(), GroupLayout.PREFERRED_SIZE, 133, GroupLayout.PREFERRED_SIZE))
				    .addComponent(getLoadReplayButton(), GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 133, GroupLayout.PREFERRED_SIZE)
				    .addComponent(getReplayDetailsButton(), GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 133, GroupLayout.PREFERRED_SIZE)
				    .addComponent(getCloseReplayButton(), GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 133, GroupLayout.PREFERRED_SIZE))
				.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
				.addComponent(getJScrollPane2(), GroupLayout.PREFERRED_SIZE, 184, GroupLayout.PREFERRED_SIZE)
				.addContainerGap());
			replayPanelLayout.setVerticalGroup(replayPanelLayout.createParallelGroup()
				.addGroup(GroupLayout.Alignment.LEADING, replayPanelLayout.createSequentialGroup()
				    .addComponent(getJScrollPane2(), 0, 203, Short.MAX_VALUE)
				    .addContainerGap())
				.addGroup(GroupLayout.Alignment.LEADING, replayPanelLayout.createSequentialGroup()
				    .addGap(12)
				    .addComponent(getLoadReplayButton(), GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE)
				    .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
				    .addComponent(getReplayDetailsButton(), GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
				    .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
				    .addComponent(getReplayListenersButton(), GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE)
				    .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
				    .addComponent(getCloseReplayButton(), GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)
				    .addContainerGap(90, 90)));
		}
		return replayPanel;
	}
	
	public JButton getAddPlayerButton() {
		if(addPlayerButton == null) {
			addPlayerButton = new JButton();
			addPlayerButton.setText("Add player");
			addPlayerButton.setBounds(17, 58, 116, 21);
		}
		return addPlayerButton;
	}
	
	public JButton getRemovePlayerButton() {
		if(removePlayerButton == null) {
			removePlayerButton = new JButton();
			removePlayerButton.setText("Remove Player");
			removePlayerButton.setBounds(17, 90, 116, 20);
		}
		return removePlayerButton;
	}
	
	private JScrollPane getJScrollPane2() {
		if(jScrollPane2 == null) {
			jScrollPane2 = new JScrollPane();
			jScrollPane2.setBounds(161, 19, 184, 178);
			jScrollPane2.setViewportView(getReplayList());
		}
		return jScrollPane2;
	}
	
	public JList getReplayList() {
		if(replayList == null) {
			ListModel replayListModel = 
				new DefaultListModel();
			replayList = new JList();
			replayList.setModel(replayListModel);
		}
		return replayList;
	}
	
	public JButton getCloseReplayButton() {
		if(closeReplayButton == null) {
			closeReplayButton = new JButton();
			closeReplayButton.setText("Close Replay");
			closeReplayButton.setBounds(17, 126, 133, 21);
		}
		return closeReplayButton;
	}
	
	public JButton getCloseServerButton() {
		if(closeServerButton == null) {
			closeServerButton = new JButton();
			closeServerButton.setText("Shutdown server");
		}
		return closeServerButton;
	}
	
	public JButton getLoadReplayButton() {
		if(loadReplayButton == null) {
			loadReplayButton = new JButton();
			loadReplayButton.setText("Load replay");
			loadReplayButton.setBounds(17, 31, 133, 21);
		}
		return loadReplayButton;
	}
	
	public JButton getReplayDetailsButton() {
		if(replayDetailsButton == null) {
			replayDetailsButton = new JButton();
			replayDetailsButton.setText("Replay Details");
			replayDetailsButton.setBounds(17, 63, 133, 20);
		}
		return replayDetailsButton;
	}
	
	public JButton getReplayListenersButton() {
		if(replayListenersButton == null) {
			replayListenersButton = new JButton();
			replayListenersButton.setText("Replay listeners");
			replayListenersButton.setBounds(17, 94, 133, 21);
		}
		return replayListenersButton;
	}

	public JButton getRefreshButton() {
		if(refreshButton == null) {
			refreshButton = new JButton();
			refreshButton.setText("Refresh");
		}
		return refreshButton;
	}
	
	private JLabel getVersionLbl() {
		if(versionLbl == null) {
			versionLbl = new JLabel();
			versionLbl.setText("Author: Mancer \r\nVersion " + AdminTools.VERSION);
			versionLbl.setHorizontalAlignment(SwingConstants.RIGHT);
		}
		return versionLbl;
	}

}
